/*
 * =====================================================================================
 *
 *       Filename:  TemplateAndTraits.cpp
 *
 *    Description:
 *
 *        Version:  1.0
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Yt (fndisme), fndisme@163.com
 *   Organization:
 *
 * =====================================================================================
 */
#include <string>
#include <iostream>
#include <type_traits>
struct Empty {

};

struct A {
	int a;
};

struct B :A {
	int b;
};

class Object {
	public:
		Object() { std::cout << "init object\n";}
		~Object() { std::cout << "uninit object\n";}
	private:
		int m_data[100];
};

char info[10000];
void placementNew() {
	auto* s = new(info)Object();

	s->~Object();
}

template<typename T>
struct EmptyHelper : T {
	int group[256];
};

struct EmptyHelper2 {
	int group[256];
};

template <typename T>
bool isEmptyClass() {
  return sizeof(EmptyHelper2) == sizeof(EmptyHelper<T>);
}

struct DummyEmpty {
	char a;
};


static void testEmptyClass() {
	std::cout << "Empty is " << sizeof(Empty) << std::endl;
	std::cout << "DummyEmpty is " << sizeof(DummyEmpty) << std::endl;
	std::cout << "Empty is " << isEmptyClass<Empty>() << std::endl;
	std::cout << "DummyEmpty is " << isEmptyClass<DummyEmpty>() << std::endl;

}

void standardLayout() {
	std::cout << "int is " << std::is_standard_layout<int>::value << std::endl;
	std::cout << "A is " << std::is_standard_layout<A>::value << std::endl;
	std::cout << "B is " << std::is_standard_layout<B>::value << std::endl;
}

int main(int /*argc*/, char** /* argv */) {
	//placementNew();
	testEmptyClass();
}

